/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package omsalonsystem.ws.Model.Business;

import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.Resource;
import javax.persistence.CascadeType;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.OneToMany;
import javax.persistence.PersistenceUnit;
import javax.transaction.UserTransaction;
import omsalonsystem.ws.Model.Servico;

/**
 *
 * @author brsolucoes.lmolinari
 */
public class ServicoBusiness extends Servico{
    
    @Resource
    private UserTransaction utx = null;
    @PersistenceUnit(unitName = "OMSalonSystemPU")
    private EntityManagerFactory emf = null;
    
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "IdServico")
    private Collection<Servico> servicoCollection;
    
    /**
     * @return the servicoCollection
     */
    public Collection<Servico> getServicoCollection() {
        return servicoCollection;
    }

    /**
     * @param servicoCollection the servicoCollection to set
     */
    public void setServicoCollection(Collection<Servico> servicoCollection) {
        this.servicoCollection = servicoCollection;
    }
    
    public EntityManager getEntityManager() {
        return emf.createEntityManager();
    }

    public ServicoBusiness(Servico servico){
        this.setNome(servico.getNome());
        this.setValor(servico.getValor());
    }
    
    public boolean CreateUpdate(){
         if (this.getServicoCollection()== null) {
            this.setServicoCollection(new ArrayList<Servico>());
        }
        EntityManager em = null;
        
        return false;
    }
    
}
